@extends('admin.layout.main')

@section('content')
    <div class="breadcrumbs ace-save-state" id="breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <i class="ace-icon fa fa-home home-icon"></i>
                <a href="/admin/index">首页</a>
            </li>
            <li>
                <a href="/admin/config">条例管理</a>
            </li>
            <li class="active"><a href="{{ url('admin/config') }}">条例列表</a></li>
        </ul><!-- /.breadcrumb -->

        <div class="nav-search" id="nav-search">
            <form class="form-search">
		<span class="input-icon">
		<input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
			<i class="ace-icon fa fa-search nav-search-icon"></i>
		</span>
            </form>
        </div><!-- /.nav-search -->
    </div>

    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="row">
                    <div class="col-xs-12">
                        <div class="clearfix">
                            <div class="pull-right tableTools-container"></div>
                        </div>
                        <div class="table-header">
                            <a href="{{ url('admin/config/create') }}">
                                <i class="menu-icon fa fa-plus orange"></i>
                                <span class="menu-text orange"> 添加条例 </span>
                            </a>
                        </div>

                        <!-- div.table-responsive -->

                        <!-- div.dataTables_borderWrap -->
                        <div>
                            <table id="dynamic-table" class="table table-striped table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>类型</th>
                                    <th>说明</th>
                                    <th class="hidden-480">添加时间</th>
                                    <th>
                                        <i class="ace-icon fa fa-clock-o bigger-110 hidden-480"></i>
                                        更新时间
                                    </th>
                                    <th class="hidden-480">操作</th>

                                    {{--<th></th>--}}
                                </tr>
                                </thead>

                                <tbody>
                                @foreach($list as $k => $v)
                                    <tr>
                                        <td>{{$page_num++}}</td>
                                        <td>{{$v->key}}</td>
                                        <td>{{$v->value}}</td>
                                        <td>{{$v->created_at}}</td>
                                        <td>{{$v->updated_at}}</td>
                                        <td>
                                            <div class="hidden-sm hidden-xs action-buttons">
                                                <a class="blue" href="#">
                                                    <i class="ace-icon fa fa-search-plus bigger-130"></i>
                                                </a>

                                                <a class="green" href="/admin/config/{{$v->id}}/edit">
                                                    <i class="ace-icon fa fa-pencil bigger-130"></i>
                                                </a>

                                                <a class="red" href="javascript:void(0);" onclick="delData('{{$v->id}}')">
                                                    <i class="ace-icon fa fa-trash-o bigger-130"></i>
                                                </a>
                                            </div>

                                            <div class="hidden-md hidden-lg">
                                                <div class="inline pos-rel">
                                                    <button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown" data-position="auto">
                                                        <i class="ace-icon fa fa-caret-down icon-only bigger-120"></i>
                                                    </button>

                                                    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                                        <li>
                                                            <a href="#" class="tooltip-info" data-rel="tooltip" title="View">
															<span class="blue">
																<i class="ace-icon fa fa-search-plus bigger-120"></i>
															</span>
                                                            </a>
                                                        </li>

                                                        <li>
                                                            <a href="/admin/config/{{$v->id}}/edit" class="tooltip-success" data-rel="tooltip" title="Edit">
															<span class="green">
																<i class="ace-icon fa fa-pencil-square-o bigger-120"></i>
															</span>
                                                            </a>
                                                        </li>

                                                        <li>
                                                            <a href="javascript:void(0);" onclick="delData('{{$v->id}}')" class="tooltip-error" data-rel="tooltip" title="Delete">
															<span class="red">
																<i class="ace-icon fa fa-trash-o bigger-120"></i>
															</span>
                                                            </a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach


                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->

            <div class="modal-footer no-margin-top">

                @if(empty($url_data))
                    {{ $list->links() }}
                @else
                    {{$list->appends($url_data)->links() }}
                @endif
            </div>
        </div><!-- /.row -->
    </div><!-- /.page-content -->

    <script>
        function delData(id) {
            var url = "{{url('admin/delete')}}/"+id;
            layer.confirm('确认删除?',{
                btn: ['确定','取消'] //按钮
            },function(){
            $.ajax({
                url:url,
                type:'get',
                success:function (resn) {
                    console.log(resn);
                    var res = JSON.parse(resn);
                    if(res.static == 1){
                        layer.msg( res.msg, {icon: 1});
                        location.href = "{{url('admin/config')}}";
                    }else {
                        layer.msg( res.msg, {icon: 2});
                    }
                }
            });
        },function(){
                //取消
            })}
    </script>
@endsection
